package com.apes.framework.plugin.condition.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.framework.plugin.condition.model.ConditionTable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * 条件表
 *
 * @author wuq
 * @create 2018-11-12 16:27
 */
public interface ConditionTableRepository extends CustomRepository<ConditionTable, String> {


    @Query("SELECT T FROM ConditionField T WHERE 1 = 1 and (T.id like %:id% or T.name like %:value%) ")
    Page<ConditionTable> find(@Param("id") String id, @Param("value") String value, Pageable pageable);

    @Query(
            value ="select t from ConditionTypes s inner join s.accessSequences a inner join a.accessSequencesItems f inner join f.conditionTable t where s.id = ?1"
    )
    List<ConditionTable> findAllByConditionTypesID(String conditionTypesID);
}
